﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Hangout.Web.Services.Text
{
    public class Text
    {
         Web.Model.HangoutDBEntities context = new Web.Model.HangoutDBEntities();

        public  DateTime GetDateTime(int userId, string text, DateTime clientDateTime, string accesstoken)
        {
            try
            {
                if (Web.Core.Accounts.User.IsValid(userId, accesstoken, context))
                {
                    return Web.Core.Text.TextManipulation.GetDateTime(text, clientDateTime);
                }
                else { throw new Web.Core.Exceptions.Account.UnAuthorisedAccess(); }
            }
            catch (System.Exception ex)
            {
                Web.Core.Exceptions.ExceptionReporting.AddAnException(userId, Web.Core.ClientType.WindowsAzure, ex, ref context);
                return DateTime.Now.AddDays(-5);
            }
        }
    }
}